package com.hjx.movie.core.util;

import org.apache.commons.text.RandomStringGenerator;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2021/1/22 - 0:57
 */
public class PasswordUtil {


    public static String generateRandomPassword(){
        char[] c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*.?".toCharArray();
        RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
                                                        .selectFrom(c).build();
        return randomStringGenerator.generate(8);
    }
    public static String generateRandomCode(Integer len){
        char[] c = "1234567890".toCharArray();
        RandomStringGenerator randomStringGenerator = new RandomStringGenerator.Builder()
                .selectFrom(c).build();
        if (len!=null&&len>=6){
            return randomStringGenerator.generate(len);
        }
        return randomStringGenerator.generate(6);
    }
//    public static void main(String[] args) {
////        Set<Integer> set1 = new HashSet<>(Arrays.asList(1,2,3,4,5));
////        Set<Integer> set2 = new HashSet<>();
////        Set<Integer> set3 = new HashSet<>(set1);
////        System.out.println(set3.removeAll(set2));
////        System.out.println(set2.removeAll(set1));
////        System.out.println(set3);
////        System.out.println(set3.isEmpty());
////        System.out.println(set2);
//    String[] s = new String[]{"Fantasy","Mystery","Thriller","Documentary"
//            ,"War","Western","Romance","Drama","Horror","Action","Sci-Fi","Music","Crime","Erotic","Adult"};
//    for (String ss:s){
//        System.out.println(ss.toUpperCase(Locale.ROOT));
//    }
//    }
}
